package com.farah.lease.web.admin.controller.slideshowInfo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.farah.lease.common.result.Result;
import com.farah.lease.model.entity.SlideshowInfo;
import com.farah.lease.web.admin.service.SlideshowInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 不爱跑步的法拉韶
 * @Date 2024-07-10__15:05
 **/
@Tag(name="轮播图管理")
@RestController
@RequestMapping("/admin/slideshowInfo")
public class SlideshowInfoController {

    @Autowired
    private SlideshowInfoService slideshowInfoService;

    @Operation(summary = "根据条件分页查询轮播图列表")
    @GetMapping("page")
    public Result<IPage<SlideshowInfo>> page(@RequestParam long current,@RequestParam long size,Long Type_id){
        IPage<SlideshowInfo> page=new Page<>(current,size);
        IPage<SlideshowInfo> result = slideshowInfoService.pageSlideshow(page,Type_id);
        return Result.ok(result);
    }

    @Operation(summary = "保存轮播图")
    @PostMapping("save")
    public Result saveSlideshow(@RequestBody SlideshowInfo slideshowInfo){
        slideshowInfoService.saveSlideshow(slideshowInfo);
        return Result.ok();
    }

    @Operation(summary = "根据id删除轮播图")
    @DeleteMapping("removeById")
    public Result removeById(@RequestParam Long id){
        slideshowInfoService.removeById(id);
        return Result.ok();
    }
}
